package model;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Hashtable;

/**
 * Class for describing a user profile
 *
 */
public class Profile implements Serializable {
	
	// Basic profile data
	private String fname;
	private String lname;
	private boolean isMale;
	private int age;
	private String occupation;
	
	// Tags of interest (could be particular artists or genres)
	private ArrayList<String> interestTags;
	
	// A list of artifacts and the rating given to them
	private Hashtable<Integer, Integer> visitedArtifacts;
	
	public Profile(String fname, String lname, boolean isMale, int age) {
		this.setFname(fname);
		this.setLname(lname);
		this.setMale(isMale);
		this.setAge(age);
		this.visitedArtifacts = new Hashtable<Integer, Integer>(); 
		this.interestTags = new ArrayList<String>();
	}
	
	
	// GETTERS AND SETTERS
	/**
	 * @return the isMale
	 */
	public boolean isMale() {
		return isMale;
	}

	/**
	 * @param isMale the isMale to set
	 */
	public void setMale(boolean isMale) {
		this.isMale = isMale;
	}

	/**
	 * @return the age
	 */
	public int getAge() {
		return age;
	}

	/**
	 * @param age the age to set
	 */
	public void setAge(int age) {
		this.age = age;
	}

	/**
	 * @return the occupation
	 */
	public String getOccupation() {
		return occupation;
	}

	/**
	 * @param occupation the occupation to set
	 */
	public void setOccupation(String occupation) {
		this.occupation = occupation;
	}

	/**
	 * @return the fname
	 */
	public String getFname() {
		return fname;
	}


	/**
	 * @param fname the fname to set
	 */
	public void setFname(String fname) {
		this.fname = fname;
	}


	/**
	 * @return the lname
	 */
	public String getLname() {
		return lname;
	}


	/**
	 * @param lname the lname to set
	 */
	public void setLname(String lname) {
		this.lname = lname;
	}


	/**
	 * @return the visitedArtifacts
	 */
	public Hashtable<Integer, Integer> getVisitedArtifacts() {
		return visitedArtifacts;
	}


	/**
	 * @param visitedArtifact The Artifact to add
	 * @param rating Number of stars to give this artifact (1-5)
	 */
	public void addVisitedArtifact(Integer visitedArtifactId, int rating) {
		
		// Check that we are adding a proper rating
		if(rating > 0 && rating < 6) {
			// Check if the artifact for some reason already exists in the mapping
			if(!this.visitedArtifacts.containsKey(visitedArtifactId)) {
				this.visitedArtifacts.put(visitedArtifactId, rating);
			}
		}
	}


	/**
	 * @return the interestTags
	 */
	public ArrayList<String> getInterestTags() {
		return interestTags;
	}


	/**
	 * Attempts to add the tag given as input to our list of interesting tags
	 * @param interestTags the tag to (attempt to) add.
	 */
	public void addInterestTag(String interestTag) {
		// Make sure the tag doesn't already exist
		if(!interestTags.contains(interestTag))
			// Add the tag
			interestTags.add(interestTag);
	}
	
	/**
	 * Attempts to remove the tag given as input from our list of interesting tags 
	 * @param interestTag The tag that is to be (attempted to) remove.
	 */
	public void removeInterestTag(String interestTag) {
		// Make sure the tag exists
		if(interestTag.contains(interestTag))
			// Remove the tag
			interestTags.remove(interestTag);
	}
}
